package cn.wolfcode.postbar.service.impl;


import cn.wolfcode.postbar.domain.UserInfo;
import cn.wolfcode.postbar.mapper.UserInfoMapper;
import cn.wolfcode.postbar.redis.service.IUserInfoRedisService;
import cn.wolfcode.postbar.service.IUserInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper,UserInfo> implements IUserInfoService {

    @Autowired
   private IUserInfoRedisService userInfoRedisService;


    /**
     * 登陆
     * @param username
     * @param password
     * @return
     */
    @Override
    public UserInfo login(String username, String password) {
        QueryWrapper<UserInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("phone",username).eq("password",password);
        UserInfo userInfo = super.getOne(wrapper);
        if (userInfo == null){
            throw new RuntimeException("账号或密码错误");
        }
        return userInfo;
    }
}
